package cn.iocoder.springboot.lab03.kafkademo.parser;

import cn.iocoder.springboot.lab03.kafkademo.entity.Resource;

import java.util.Properties;

/**
 * @Author：YH
 * @Description：
 * @Date:Created in 2023/12/30 16:41
 */
public abstract class AbstractResourceParser<R> implements ResourceParser<R> {

    @Override
    public Resource parse(R request, String type) {
        String namespaceId = getNamespaceId(request);
        String group = getGroup(request);
        String name = getResourceName(request);
        Properties properties = getProperties(request);
        return new Resource(namespaceId, group, name, type, properties);
    }

    protected abstract String getNamespaceId(R request);

    protected abstract String getGroup(R request);

    protected abstract String getResourceName(R request);

    protected abstract Properties getProperties(R request);
}
